objs = a.o b.o c.o
dep_files := $(patsubst %.o, .%.o.d, $(objs))

dep_files := $(wildcard $(dep_files))

CFLAGS = -Werror

test: a.o b.o c.o
	gcc -o test $^
	@echo dep_files = $(dep_files)

ifneq ($(dep_files),)
include $(dep_files)
endif

c.o: c.c c.h

%.o : %.c
	gcc $(CFLAGS) -c -o $@ $< -MD -MF .$@.d

clean:
	rm *.o test

distclean: clean
	rm $(dep_files)